<?php
if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Email extends CI_Controller{
    
    function send(){
        $attach = 'dog.gif';
        if(file_exists($attach)){
            $config = array(
                'protocol' => 'smtp',
                'smtp_host' => 'smtp.sina.com',
                'smtp_port' => 25,
                'smtp_user' => '',
                'smtp_pass' => '',
                'charset' => 'utf-8',
            );
            $this->load->library('email' , $config);
            $this->email->set_newline("\r\n");
            
            $this->email->from('' , '测试邮箱');
            $this->email->to('');
            $this->email->subject('THIS is A test email');
            $this->email->message('This is a TEST CI email class,这只是个测试邮件，测试下是否能够发送成功');
            $this->email->attach($attach);
            if($this->email->send()){
                echo 'send mail ok';
            }else{
                show_error($this->email->print_debugger());
            }
        }else{
            show_error('附件不存在['.$attach.']');
        }
    }
}
?>